home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
pascal
/
gsdbloo.exe
/
DEMOU003.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-02-23
|
3KB
|
107 lines
program DemoU003;
{------------------------------------------------------------------------------
DBase Index Creator
Useless Examples
Demo Program
Copyright (c) Richard F. Griffin
10 February 1992
102 Molded Stone Pl
Warner Robins, GA 31088
-------------------------------------------------------------
Unit to demonstrate index processing.
The DEMOU3.DBF file will be created by using the MakeTestData
procedure in GS_GENF.PAS.
The IndexTo routine will be used to index on LASTNAME.
The contents of the index file will be printed.
The indexed file will be listed ascending and descending.
Finally, Find is called using the LASTNAME in physical record
25. The record number of the first occurrence of the name will
be returned.
-------------------------------------------------------------------------------}
uses
CRT,
DOS,
printer,
GS_Strng,
GS_dBFld,
GS_dBase,
GS_GenF;
var
MyFile : GS_dBFld_Objt;
s : string;
li : boolean;
i : integer;
c : char;
ms : string[30];
begin
ClrScr;
writeln('Creating DemoU3.DBF');
MakeTestData('DemoU3', 50, false);
writeln('DemoU3.DBF Created');
MyFile.Init('DemoU3');
MyFile.Open;
MyFile.IndexTo('DemoU3','LASTNAME');
MyFile.Index('DemoU3');
MyFile.dbfNdxTbl[1]^.KeyList('prn');
i := 0;
MyFile.GetRec(Top_Record);
while (not MyFile.File_EOF) do
begin
inc(i);
if (i mod 23) = 0 then
begin
write('Press any key to continue.');
c := ReadKey;
writeln;
end;
s := MyFile.FieldGet('LASTNAME');
s[0] := #30;
writeln(MyFile.RecNumber:8,' ',s,i:6);
MyFile.GetRec(Next_Record);
end;
writeln('End of Ascending check, Now for descending...');
writeln('Press any key to continue.');
c := ReadKey;
i := 0;
MyFile.GetRec(Top_Record); {do this to move from end at start}
MyFile.GetRec(Bttm_Record);
while (not MyFile.File_TOF) do
begin
inc(i);
if (i mod 23) = 0 then
begin
write('Press any key to continue.');
c := ReadKey;
writeln;
end;
s := MyFile.FieldGet('LASTNAME');
s[0] := #30;
writeln(MyFile.RecNumber:8,' ',s,i:6);
if MyFile.RecNumber = 25 then ms := s;
MyFile.GetRec(Prev_Record);
end;
ms := TrimR(ms);
li := MyFile.Find(ms);
writeln('The first record for ',ms,' is ',MyFile.RecNumber);
MyFile.Close;
end.